let stringList1 = ["周一","周二","周三","周四","周五","周六","周日"];
let stringList2 = ["（1，2）","（3，4）","（5，6）","（7，8）","（9，10）","（11，12）"];

function getCourse(){
    console.log("111");
    let userID = document.getElementById("person-img").title;
    fetch('/courseList', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({userID: userID})
    })
        .then(response => response.json())
        .then(datalist => {

            // console.log(datalist);
            displayInfo(datalist);
            console.log("success");
        })
        .catch(error => {
            console.error('There has been a problem with your fetch operation:', error);
        })
}

function displayInfo(dataList){
    let couNames = dataList.couNames;
    let couLocations = dataList.couLocations;
    let couTeachers = dataList.couTeachers;
    let date = dataList.couTimes;
    for(var k=0;k<Object.keys(date).length;k++){
        for (let i = 0; i < stringList1.length; i++) {
            for (let j = 0; j < stringList2.length; j++) {
                let searchString = stringList1[i] + stringList2[j];
                if (date[k].includes(searchString)) {
                    var rowId = 'stu-list-td' + (j + 1);
                    var row = document.getElementById(rowId);
                    let text = couNames[k]+"/"+couLocations[k]+"/"+couTeachers[k];
                    row.cells[i+1].textContent = text;
                }
            }
        }
    }
}